package client;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;

import javax.swing.*;

public class DisplayWindow extends JFrame implements ActionListener,Serializable {

	private JTextArea testo;
	private JButton ok;
	
	
	public DisplayWindow(String s){
		
		super("DisplayWindow");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		JPanel pannello = new JPanel();
		pannello.setLayout(new GridLayout(1,2));
		
		ok = new JButton("OK");
		ok.setPreferredSize(new Dimension(30,50));
		ok.addActionListener(this);
		testo = new JTextArea(s + "\n");
		testo.setLineWrap(true);
		testo.setWrapStyleWord(true);
		testo.setPreferredSize(new Dimension(300,50));
				
		testo.setBackground(Color.LIGHT_GRAY);
		testo.setOpaque(true);
		pannello.add(testo);

		pannello.add(ok);
		
		add(pannello);
		pack();
		validate();
		setVisible(true);
		
		synchronized(this){
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
		
	public void actionPerformed(ActionEvent e) {
		synchronized(this){
			notifyAll();
			dispose();
			}
	}
	
}
